package com.company;

import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.ArrayList;

public class Main {

    public static void main(String[] args) {
        String fileNameStr = "";
        //左上角坐标
        Double x1 = 0.0;
        Double y1 = 0.0;
        //右下角坐标
        Double x2 = 0.0;
        Double y2 = 0.0;
        //切割后的List集合
        ArrayList<String> fileNameList = new ArrayList<String>();
        //java获取12套背景图
        ArrayList<String> bacList = new ArrayList<>();
        File bacFile = new File("D:/图片素材/210929/moban");
        File[] bacFiles = bacFile.listFiles();
        for (int i = 0; i < bacFiles.length; i++) {
            File file1 = bacFiles[i];
            String fileName = file1.getName();
            String prefix = fileName.substring(fileName.lastIndexOf(".") + 1)
                    .toLowerCase();
            if ("jpg".equals(prefix) || "png".equals(prefix)
                    || "bmp".equals(prefix) || "gif".equals(prefix)) {
                bacList.add(fileName);
            }
        }
        //java获取ui图的所有图片
        File fileUi = new File("D:/图片素材/210929/ui");
        File[] fileUis = fileUi.listFiles();
        ArrayList<String> uiList = new ArrayList();
        for (int i = 0; i < fileUis.length; i++) {
            File file1 = fileUis[i];
            String fileName = file1.getName();
            String prefix = fileName.substring(fileName.lastIndexOf(".") + 1)
                    .toLowerCase();
            if ("jpg".equals(prefix) || "png".equals(prefix)
                    || "bmp".equals(prefix) || "gif".equals(prefix)) {
                uiList.add(fileName);
            }
        }
        //java获取框架文件里所有图片
        ArrayList<String> list = new ArrayList();
        File file = new File("D:/图片素材/210929/kuangjia");
        File[] files = file.listFiles();
        for (int i = 0; i < files.length; i++) {
            File file1 = files[i];
            String fileName = file1.getName();
            String prefix = fileName.substring(fileName.lastIndexOf(".") + 1)
                    .toLowerCase();
            if ("jpg".equals(prefix) || "png".equals(prefix)
                    || "bmp".equals(prefix) || "gif".equals(prefix)) {
                list.add(fileName);
            }
        }

        for (String s:
                list) {
            String[] splitStrings = s.split("_");
            System.out.println(s);
            if(splitStrings[0] != null){
                fileNameStr = splitStrings[0];
            }
            if(splitStrings[1] != null){
                x1 = Double.parseDouble(splitStrings[1]);
            }
            if(splitStrings[2] != null){
                y1 = Double.parseDouble(splitStrings[2]);
            }
            if(splitStrings[3] != null){
                x2 = Double.parseDouble(splitStrings[3]);
            }
            if(splitStrings[4] != null){
                y2 = Double.parseDouble(splitStrings[4]);
            }

            double ux = x2 - x1;
            double uy = y2 - y1;


//            for (String s2:
//                    uiList) {
//                Main.margeImage();
//            }
            //遍历背景图
            int index = 1;
            for (String s1:
                 bacList) {
                //System.out.println(s1);
                int col = 0;
                try {
                    if(index == 1){
                        col = 1;
                    }
                    if(index == 2){
                        col = 2;
                    }
                    if(index == 3){
                        col = 3;
                    }
                    if(index == 4){
                        col = 4;
                    }
                    if(index == 5){
                        col = 5;
                    }
                    if(index == 6){
                        col = 6;
                    }
                    if(index == 7){
                        col = 7;
                    }
                    if(index == 8){
                        col = 8;
                    }
                    if(index == 9){
                        col = 9;
                    }
                    if(index == 10){
                        col = 10;
                    }
                    if(index == 11){
                        col = 11;
                    }
                    if(index == 12){
                        col = 12;
                    }
//                    uiList.get(0);
//                    Main.margeImage1("D:\\图片素材\\210929\\kuangjia\\"+s,"D:\\图片素材\\210929\\ui\\"+uiList.get(0),"D:\\图片素材\\210929\\merImage\\1.png", x1, y1, x2, y2);
                    File file11 = new File("D:\\图片素材\\210929\\result\\"+fileNameStr);
                    if(!file11.exists()){
                        file11.mkdir();
                    }
                    System.out.println(s1+",,"+col+",,"+ux+",,"+uy+",,"+x1+",,"+y1);
                    Main.margeImage("D:\\图片素材\\210929\\moban\\"+s1,"D:\\图片素材\\210929\\kuangjia\\"+s,"D:\\图片素材\\210929\\result\\"+fileNameStr+"\\"+s1,col,ux,uy,x1,y1);
                    index++;
                }catch (Exception e){

                }

            }

        }


	// write your code here
//        try {
//            Main.margeImage("D:\\图片素材\\背景\\becloud.png", "D:\\图片素材\\VW\\11.png","D:\\图片素材\\UI\\2.png","D:\\图片素材\\2.png", "D:\\图片素材\\结果\\1.png");
//        }catch (Exception e){
//
//        }
////        try {
//            Main.updateImage("D:\\图片素材\\UI\\1.png","D:\\图片素材\\UI\\2.png");
//        }catch (Exception e){
//
//        }

    }
    public static void margeImage(String path1,String path2,String outPath,Integer col,Double ux, Double uy,Double x13,Double y13) throws IOException {
        //System.out.println("000");
        File file = new File(path1);
        Image img = ImageIO.read(file);
//水印宽度
        int width = img.getWidth(null);
//水印高
        int height = img.getHeight(null);
        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = bi.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g.drawImage(img.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0, 0, null);
        ImageIcon imgIcon = new ImageIcon(path2);
        ImageIcon imgIcon3 = new ImageIcon("D:\\图片素材\\210929\\ui\\1.png");


//宽
        int imgIconWidth = imgIcon.getIconWidth();
//高
        int imgIconHeight = imgIcon.getIconHeight();

        int imgIcon3Width = imgIcon3.getIconWidth();

        int imgIcon3height = imgIcon3.getIconHeight();
        Image con = imgIcon.getImage();
        Image con3 = imgIcon3.getImage();

//透明度
        float clarity = 1.0f;
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, clarity));
        //第一套图片居中
        int x = 0;
        int y = 0;
        int ux13 = 0;
        int uy13 = 0;
        int xI = 0;
        int yI = 0;
        int ux1 = 0;
        int uy1 = 0;
        if(col == 1){
            //将框架图进行等比的压缩或放大
           // Main.updateImage();
            int x1 = 172;
            int y1 = 176;
            int x11 = 812;
            int y11 = 637;
            int xSize = x11 - x1;
            int ySize = y11 - y1;
            if(imgIconWidth > xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                   xI = xSize;
                   yI = (int) (imgIconHeight - (xc/il));
                   ux1 = (int) (ux * xI/imgIconWidth);
                   uy1 = (int) (uy * yI/imgIconHeight);
                   ux13 = (int)(x13 * xI/imgIconWidth);
                   uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }
            if(imgIconWidth > xSize && imgIconHeight == ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);


            }
            if(imgIconWidth > xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight < ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth < xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight + (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth + (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }

            imgIcon.setImage(imgIcon.getImage().getScaledInstance(xI,yI,Image.SCALE_DEFAULT));
            imgIcon3.setImage(imgIcon3.getImage().getScaledInstance(ux1,uy1,Image.SCALE_DEFAULT));
//            g.drawImage(con, x1, y1, null);
            con = imgIcon.getImage();
            con3 = imgIcon3.getImage();
            x = (width-xI)/2;
            y = y1+((ySize-yI)/2);
        }
        if(col == 2){
            int x2 = 121;
            int y2 = 188;
            int x21 = 621;
            int y21 = 653;
            //将框架图进行等比的压缩或放大
            int xSize = x21 - x2;
            int ySize = y21 - y2;
            if(imgIconWidth > xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }
            if(imgIconWidth > xSize && imgIconHeight == ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);


            }
            if(imgIconWidth > xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight < ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth < xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }

            imgIcon.setImage(imgIcon.getImage().getScaledInstance(xI,yI,Image.SCALE_DEFAULT));
            imgIcon3.setImage(imgIcon3.getImage().getScaledInstance(ux1,uy1,Image.SCALE_DEFAULT));
//            g.drawImage(con, x1, y1, null);
            con = imgIcon.getImage();
            con3 = imgIcon3.getImage();
            x = (xSize-xI)/2+x2;
            y = y2+((ySize-yI)/2);

        }
        if(col == 3){
            int x3 = 335;
            int y3 = 205;
            int x31 = 940;
            int y31 = 790;
            int xSize = x31 - x3;
            int ySize = y31 - y3;
            if(imgIconWidth > xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }
            if(imgIconWidth > xSize && imgIconHeight == ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);


            }
            if(imgIconWidth > xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight < ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth < xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }

            imgIcon.setImage(imgIcon.getImage().getScaledInstance(xI,yI,Image.SCALE_DEFAULT));
            imgIcon3.setImage(imgIcon3.getImage().getScaledInstance(ux1,uy1,Image.SCALE_DEFAULT));
//            g.drawImage(con, x1, y1, null);
            con = imgIcon.getImage();
            con3 = imgIcon3.getImage();
            x = (xSize-xI)/2+x3;
            y = y3+((ySize-yI)/2);
        }
        if(col == 4){
            int x4 = 335;
            int y4 = 205;
            int x41 = 940;
            int y41 = 790;
            int xSize = x41 - x4;
            int ySize = y41 - y4;
            if(imgIconWidth > xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }
            if(imgIconWidth > xSize && imgIconHeight == ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);


            }
            if(imgIconWidth > xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight < ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth < xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }

            imgIcon.setImage(imgIcon.getImage().getScaledInstance(xI,yI,Image.SCALE_DEFAULT));
            imgIcon3.setImage(imgIcon3.getImage().getScaledInstance(ux1,uy1,Image.SCALE_DEFAULT));
//            g.drawImage(con, x1, y1, null);
            con = imgIcon.getImage();
            con3 = imgIcon3.getImage();
            x = (xSize-xI)/2+x4;
            y = y4+((ySize-yI)/2);

        }
        if(col == 5){
            int x5 = 335;
            int y5 = 205;
            int x51 = 940;
            int y51 = 790;
            int xSize = x51 - x5;
            int ySize = y51 - y5;
            if(imgIconWidth > xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }
            if(imgIconWidth > xSize && imgIconHeight == ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);


            }
            if(imgIconWidth > xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight < ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth < xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }

            imgIcon.setImage(imgIcon.getImage().getScaledInstance(xI,yI,Image.SCALE_DEFAULT));
            imgIcon3.setImage(imgIcon3.getImage().getScaledInstance(ux1,uy1,Image.SCALE_DEFAULT));
//            g.drawImage(con, x1, y1, null);
            con = imgIcon.getImage();
            con3 = imgIcon3.getImage();
            x = (xSize-xI)/2+x5;
            y = y5+((ySize-yI)/2);

        }
        if(col == 6){
            int x6 = 335;
            int y6 = 205;
            int x61 = 940;
            int y61 = 790;
            int xSize = x61 - x6;
            int ySize = y61 - y6;
            if(imgIconWidth > xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }
            if(imgIconWidth > xSize && imgIconHeight == ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);


            }
            if(imgIconWidth > xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight < ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth < xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }

            imgIcon.setImage(imgIcon.getImage().getScaledInstance(xI,yI,Image.SCALE_DEFAULT));
            imgIcon3.setImage(imgIcon3.getImage().getScaledInstance(ux1,uy1,Image.SCALE_DEFAULT));
//            g.drawImage(con, x1, y1, null);
            con = imgIcon.getImage();
            con3 = imgIcon3.getImage();
            x = (xSize-xI)/2+x6;
            y = y6+((ySize-yI)/2);

        }
        if(col == 7){
            int x7 = 335;
            int y7 = 205;
            int x71 = 940;
            int y71 = 790;
            int xSize = x71 - x7;
            int ySize = y71 - y7;
            if(imgIconWidth > xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }
            if(imgIconWidth > xSize && imgIconHeight == ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);


            }
            if(imgIconWidth > xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight < ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth < xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }

            imgIcon.setImage(imgIcon.getImage().getScaledInstance(xI,yI,Image.SCALE_DEFAULT));
            imgIcon3.setImage(imgIcon3.getImage().getScaledInstance(ux1,uy1,Image.SCALE_DEFAULT));
//            g.drawImage(con, x1, y1, null);
            con = imgIcon.getImage();
            con3 = imgIcon3.getImage();
            x = (xSize-xI)/2+x7;
            y = y7+((ySize-yI)/2);

        }
        if(col == 8){
            int x8 = 335;
            int y8 = 205;
            int x81 = 940;
            int y81 = 790;
            int xSize = x81 - x8;
            int ySize = y81 - y8;
            if(imgIconWidth > xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }
            if(imgIconWidth > xSize && imgIconHeight == ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);


            }
            if(imgIconWidth > xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight < ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth < xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }

            imgIcon.setImage(imgIcon.getImage().getScaledInstance(xI,yI,Image.SCALE_DEFAULT));
            imgIcon3.setImage(imgIcon3.getImage().getScaledInstance(ux1,uy1,Image.SCALE_DEFAULT));
//            g.drawImage(con, x1, y1, null);
            con = imgIcon.getImage();
            con3 = imgIcon3.getImage();
            x = (xSize-xI)/2+x8;
            y = y8+((ySize-yI)/2);

        }
        if(col == 9){
            int x9 = 335;
            int y9 = 205;
            int x91 = 940;
            int y91 = 790;
            int xSize = x91 - x9;
            int ySize = y91 - y9;
            if(imgIconWidth > xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }
            if(imgIconWidth > xSize && imgIconHeight == ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);


            }
            if(imgIconWidth > xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight < ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth < xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }

            imgIcon.setImage(imgIcon.getImage().getScaledInstance(xI,yI,Image.SCALE_DEFAULT));
            imgIcon3.setImage(imgIcon3.getImage().getScaledInstance(ux1,uy1,Image.SCALE_DEFAULT));
//            g.drawImage(con, x1, y1, null);
            con = imgIcon.getImage();
            con3 = imgIcon3.getImage();
            x = (xSize-xI)/2+x9;
            y = y9+((ySize-yI)/2);

        }
        if(col == 10){
            int x10 = 335;
            int y10 = 205;
            int x101 = 940;
            int y101 = 790;
            int xSize = x101 - x10;
            int ySize = y101 - y10;
            if(imgIconWidth > xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }
            if(imgIconWidth > xSize && imgIconHeight == ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);


            }
            if(imgIconWidth > xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight < ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth < xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }

            imgIcon.setImage(imgIcon.getImage().getScaledInstance(xI,yI,Image.SCALE_DEFAULT));
            imgIcon3.setImage(imgIcon3.getImage().getScaledInstance(ux1,uy1,Image.SCALE_DEFAULT));
//            g.drawImage(con, x1, y1, null);
            con = imgIcon.getImage();
            con3 = imgIcon3.getImage();
            x = (xSize-xI)/2+x10;
            y = y10+((ySize-yI)/2);
        }
        if(col == 11){
            int x11 = 335;
            int y11 = 205;
            int x111 = 940;
            int y111 = 790;
            int xSize = x111 - x11;
            int ySize = y111 - y11;
            if(imgIconWidth > xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }
            if(imgIconWidth > xSize && imgIconHeight == ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);


            }
            if(imgIconWidth > xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight < ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth < xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }

            imgIcon.setImage(imgIcon.getImage().getScaledInstance(xI,yI,Image.SCALE_DEFAULT));
            imgIcon3.setImage(imgIcon3.getImage().getScaledInstance(ux1,uy1,Image.SCALE_DEFAULT));
//            g.drawImage(con, x1, y1, null);
            con = imgIcon.getImage();
            con3 = imgIcon3.getImage();
            x = (xSize-xI)/2+x11;
            y = y11+((ySize-yI)/2);

        }
        if(col == 12){
            int x12 = 140;
            int y12 = 160;
            int x121 = 880;
            int y121 = 840;
            int xSize = x121 - x12;
            int ySize = y121 - y12;
            if(imgIconWidth > xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }
            if(imgIconWidth > xSize && imgIconHeight == ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);


            }
            if(imgIconWidth > xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                //将长缩小到和背景定位的长一致
                xI = xSize;
                yI = (int) (imgIconHeight - (xc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth == xSize && imgIconHeight < ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight > ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                yI = ySize;
                xI = (int)(imgIconWidth - (yc/il));
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);

            }
            if(imgIconWidth < xSize && imgIconHeight == ySize){
                xI = xSize;
                yI = ySize;
                ux1 = (int) (ux * xI/imgIconWidth);
                uy1 = (int) (uy * yI/imgIconHeight);
                ux13 = (int)(x13 * xI/imgIconWidth);
                uy13 = (int)(y13 * yI/imgIconHeight);
            }
            if(imgIconWidth < xSize && imgIconHeight < ySize){
                double xc = (double)imgIconWidth - (double)xSize;
                double yc = (double)imgIconHeight - (double)ySize;
                double il = (double)imgIconWidth/(double)imgIconHeight;
                double cl = xc/yc;
                if(cl >= il){
                    //将长缩小到和背景定位的长一致
                    xI = xSize;
                    yI = (int) (imgIconHeight - (xc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);

                }else {
                    //将宽缩小到和背景定位的宽一致
                    yI = ySize;
                    xI = (int)(imgIconWidth - (yc/il));
                    ux1 = (int) (ux * xI/imgIconWidth);
                    uy1 = (int) (uy * yI/imgIconHeight);
                    ux13 = (int)(x13 * xI/imgIconWidth);
                    uy13 = (int)(y13 * yI/imgIconHeight);
                }
            }

            imgIcon.setImage(imgIcon.getImage().getScaledInstance(xI,yI,Image.SCALE_DEFAULT));
            imgIcon3.setImage(imgIcon3.getImage().getScaledInstance(ux1,uy1,Image.SCALE_DEFAULT));
//            g.drawImage(con, x1, y1, null);
            con = imgIcon.getImage();
            con3 = imgIcon3.getImage();
            x = (xSize-xI)/2+x12;
            y = y12+((ySize-yI)/2);

        }


//水印的位置
        g.drawImage(con3,x+ux13, y+uy13, null);
        g.drawImage(con, x, y, null);

        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
        g.dispose();
        File sf = new File(outPath);
// 保存图片
        ImageIO.write(bi, "png", sf);


    }
    public static void margeImage1(String path1,String path2,String outPath, Double x1, Double y1, Double x2, Double y2) throws IOException {
        System.out.println("111");
        //获取框架里的图片的长和框
        Double xSize = x2 - x1;
        Double ySize = y2 - y1;
        //将ui图进行缩小或放大
        Main.updateImage(path2,"D:\\图片素材\\210929\\ui\\ui.png",xSize,ySize);
        File file = new File(path1);
        Image img = ImageIO.read(file);
//水印宽度
        int width = img.getWidth(null);
//水印高
        int height = img.getHeight(null);
        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = bi.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g.drawImage(img.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0, 0, null);
        ImageIcon imgIcon = new ImageIcon("D:\\图片素材\\210929\\ui\\ui.png");

//宽
        int imgIconWidth = imgIcon.getIconWidth();
//高
        int imgIconHeight = imgIcon.getIconHeight();
        Image con = imgIcon.getImage();

//透明度
        float clarity = 1.0f;
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, clarity));
//水印的位置
        g.drawImage(con, x1.intValue(), y1.intValue(), null);

        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
        g.dispose();
        File sf = new File(outPath);
// 保存图片
        ImageIO.write(bi, "png", sf);


    }
    public static void updateImage(String inPath,String outPath, Double xSize, Double ySize) throws IOException{

        InputStream inputStream = new FileInputStream(new File(inPath));

        BufferedImage bufferedImage = ImageIO.read(inputStream);

        int height = bufferedImage.getHeight(); //图片的高
        int width = bufferedImage.getWidth();  //图片的宽

        int newWidth = xSize.intValue();
        int newHeight =ySize.intValue();
        //
//        if(wid>width){
//            double s = wid/width;
//            newHeight = (int) ((int) height*s);
//            newWidth = (int) ((int) width*s);
//        }
//        if(wid<width){
//            double s = width/wid;
//            newHeight = (int) ((int) height/s);
//            newWidth = (int) ((int) width/s);
//        }

        BufferedImage image = new BufferedImage(newWidth,newHeight, BufferedImage.TYPE_INT_BGR);

        Graphics garphics = image.createGraphics();
        garphics.drawImage(bufferedImage, 0, 0, newWidth, newHeight, null);

        OutputStream outputStream = new FileOutputStream(new File(outPath));

        JPEGImageEncoder j = JPEGCodec.createJPEGEncoder(outputStream);
        j.encode(image);

        outputStream.close();

    }
}
